package util.file;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class FileWrtUtil {

	public static void write(String filepath, String content){
		write(filepath, content, true);
	}
	
	public static void write(String filepath, String content, boolean append){
		File f = new File(filepath);
		File dir = new File(f.getParent());
		
		if(!dir.exists()) dir.mkdirs();
		
		FileWriter fw = null;
		try {
			fw = new FileWriter(f, append);
			
			fw.write(content + "\n");
			fw.close();
			
		} catch (IOException e) {
			e.getStackTrace();
		}
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		for(int i = 0; i < 100; i++){
			FileWrtUtil.write("res2/test.txt", "test" + i, true);
		}

	}

}
